/* 
 *  <copyright file="GraphicScaleCmp.cs" company="Wesley Jowitt">
 *  
 *  SobrietyEngine: Copyright (c) 2011 Wesley Jowitt
 *  
 *  This software is distributed under a software license.
 *   * As of the creation time of this file, the license in use is the Microsoft Permissive License (Ms-PL) 
 *    * The license can be viewed at:
 *     * License.Txt in the root folder of this project
 *      * http://sobrietyengine.codeplex.com/license
 *       * http://www.microsoft.com/opensource/licenses.mspx
 *       
 *  </copyright>
 *   */

using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;
using SobrietyEngine.Common;

namespace SobrietyEngine.Components.Common
{
    public class ScaleCmp:BaseComponent, IScale, IComponent
    {
        Vector3 scale = Vector3.One;
        public Vector3 Scale { get { return scale; } private set { scale = value; } } 

        public ScaleCmp()
            : base()
        {
            Scale = new Vector3(1.0f, 1.0f, 1.0f);
        }

        public ScaleCmp(Vector3 _scale)
            : base()
        {
            Scale = _scale;
        }

        public override List<ParameterDescription> GetParameterDescriptions()
        {
            List<ParameterDescription> d = new List<ParameterDescription>();
            d.Add(new ParameterDescription("X", "X scale value", typeof(float), (float)0));
            d.Add(new ParameterDescription("Y", "Y scale value", typeof(float), (float)0));
            d.Add(new ParameterDescription("Z", "Z scale value", typeof(float), (float)0));
            return d;
        }

        override public void Set(Parameters parms)
        {
            scale.X = parms.GetValueAs<float>("X", 1f);
            scale.Y = parms.GetValueAs<float>("Y", 1f);
            scale.Z = parms.GetValueAs<float>("Z", 1f);
        }

        override public Type[] SupportedInterfaces()
        {
            return new Type[] { typeof(IScale) };
        }

        public void Set(Vector3 scale)
        {
            this.Scale = scale;
        }

        public Vector3 Get()
        {
            return Scale;
        }

        public void Add(Vector3 scale)
        {
            Scale += scale;
        }
    }
}